﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Editor.Particles
{
    public class Particle
    {
        public Vector2 Position;
        public Vector2 Velocity;
        public Vector2 Acceleration;

        public float Rotation;                  
        public float RotationSpeed;

        //How long the particle should stay alive
        public float Lifetime;
        //Time since the particle was created
        public float ParticleElapsedTime;
        //The scale of the particle
        public float Scale;
        //Returns whether the particle is still active or not
        public bool IsActive()
        {
            if (Lifetime > ParticleElapsedTime)
                return false;
            else
                return true;
        }
        //Initialization of the particle
        public void Initialize(Vector2 thePosition, Vector2 theVelocity, Vector2 theAcceleration, float theLifetime, float theScale, float theRotationSpeed, float theRotation)
        {
            this.Position = thePosition;
            this.Velocity = theVelocity;
            this.Acceleration = theAcceleration;
            this.Lifetime = theLifetime;
            this.Scale = theScale;
            this.RotationSpeed = theRotationSpeed;
            this.Rotation = theRotation;
            this.ParticleElapsedTime = 0.0f;

        }
        //Update the particle
        public void Update(float Delta)
        {
            Velocity += Acceleration * Delta;
            Position += Velocity * Delta;
            Rotation += RotationSpeed * Delta;
            ParticleElapsedTime += Delta;
        }
    }
}
